package com.zzyl.mapper;

import com.github.pagehelper.Page;
import com.zzyl.dto.DevicePageQueryDto;
import com.zzyl.entity.Device;
import com.zzyl.vo.DeviceVo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface DeviceMapper {
    int deleteByPrimaryKey(Long id);

    int insert(Device record);

    int insertSelective(Device record);

    Device selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(Device record);

    int updateByPrimaryKey(Device record);

    /**
     * 这是Mybatis Generator拓展插件生成的方法(请勿删除).
     * This method corresponds to the database table device
     *
     * @mbg.generated
     * @author hewei
     */
    int batchInsert(@Param("list") List<Device> list);
    /**
     * 根据设备名字查询数量
     *
     * **/
    @Select("select  count(*) from  device where  device_name = #{deviceName}")
    Long findCountByDeviceName(String deviceName);

    Page<DeviceVo> selectByPage(DevicePageQueryDto devicePageQueryDto);

    DeviceVo findByIotId(String iotId);
     @Delete("delete  from  device where iot_id = #{iotId}")
    Object deleteByIotId(String iotId);
   @Select("select  * from device_data  where  alarm_time > date_sub(NOW(),INTERVAL 30 day )")
    void updateStatus(LocalDateTime now);
    List<Long> selectNursingIdsByIotIdWithElder(String iotId);

    List<Long> selectNursingIdsByIotIdWithBed(String iotId);

    List<Device> selectByIOTId(List<String> iotIdList);
}